import Vue from 'vue'
import VueRouter from 'vue-router'
import home from "@/views/admin/Home.vue";
import Login from "@/views/login/login.vue";
import bookManage from "@/views/admin/book/bookManage.vue";
import bookAdd from "@/views/admin/book/bookAdd.vue";
import productDetails from "@/views/user/productDetails.vue";
import shopCar from "@/views/user/shopCar.vue";
import userInfo from "@/views/user/userInfo/userInfo.vue";

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  {
    path: '/index',
    name: '用户页面',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/user/index.vue')
  },
  {
    path: '/productDetail',
    name: 'productDetail',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: productDetails
  },
  {
    path: '/userInfo',
    name:'userInfo',
    component: userInfo
  },
  {
    path:'/shopCar',
    name:'shopCar',
    component: shopCar
  },
    //后台管理路由
  {
    path: '/home',
    name: 'Home',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/admin/Home.vue'),
    children:[
      {
        path:'/',
        name:'图书管理',
        component: bookManage
      },{
       path:'bookManage',
        name:'图书管理',
        component: bookManage
      },{
        path:'bookAdd',
        name:'图书添加',
        component: bookAdd
      }


    ]

  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
